<?php

/**
 * KTDTopic form.
 *
 * @package    s-test
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class KTDTopicForm extends BaseKTDTopicForm
{
  public function configure()
  {
      
      $this->embedForm('first_message', new KTDMessageForm());
      unset($this['created_at'],
             $this['updated_at'],
              $this['forum_id']);
      $this->validatorSchema['title'] = new sfValidatorString(array('required' =>true));
  }

  public function updateObject($values = null){
        parent::updateObject($values);

        //on va créer le message...
        $values = $this->getValues();
        $msg = new KTDMessage();
        $msg->fromArray($values['first_message']);
        $msg->setPlayerId($this->getOption('player_id'));
        $msg->setKTDTopic($this->getObject());


        //On sauvegarde le premier message
        $this->embeddedForms["first_message"] = new KTDMessageForm($msg);
      return $this->object;
  }
}
